package cn.isjinhao.crws.util;

import java.math.BigDecimal;

/**
 * @author 01395265
 * @date 2021/3/2
 */
public class BigDecimalUtil {

    public static BigDecimal plus(BigDecimal left, BigDecimal right) {
        return left.add(right);
    }

    public static BigDecimal subtract(BigDecimal left, BigDecimal right) {
        return left.subtract(right);
    }

    public static BigDecimal multiply(BigDecimal left, BigDecimal right) {
        return left.multiply(right);
    }

    public static BigDecimal divide(BigDecimal left, BigDecimal right) {
        return left.divide(right);
    }

    /**
     * left < right, 返回真
     * left > right, 返回假
     */
    public static Boolean less(BigDecimal left, BigDecimal right) {
        return left.compareTo(right) < 0;
    }

    public static Boolean equal(BigDecimal left, BigDecimal right) {
        return left.compareTo(right) == 0;
    }

    public static Boolean greater(BigDecimal left, BigDecimal right) {
        return left.compareTo(right) > 0;
    }

    public static Boolean greaterEqual(BigDecimal left, BigDecimal right) {
        return greater(left, right) || equal(left, right);
    }

    public static Boolean lessEqual(BigDecimal left, BigDecimal right) {
        return less(left, right) || equal(left, right);
    }

}
